home *** CD-ROM | disk | FTP | other *** search
- unit PrefsGlobals;
-
- { This code is part of the Finger/Fingerd source code, written in THINK Pascal 4 }
- { Copyright 1991-1992 Peter N Lewis }
- { If you use this code, you must give me credit in your about box and documentation }
-
- interface
-
- const
- prefs_version = $010;
- prefsCreator = 'PnLF';
- prefsType = 'PnLF';
- prefsResType = 'PREF';
- prefsResID = 128;
- prefsStrhResID = 128;
- prefsNameStrhIndex = 1;
- prefsFinderCommentStrhIndex = 2;
-
- type
- { DONT REORDER THIS RECORD OR THESE TYPES! }
- prefsRecord = record
- version: integer;
- showIP: boolean;
- autoopen: boolean;
- dummy: array[3..15] of boolean;
- plan_enabled: boolean; { plan enabled }
- plan_dirID: longInt;
- plan_vrn: integer; { In memory only }
- plan_CrDate: longInt; { volume creation date, on disk only }
- plan_volume: str63; { volume name, on disk only }
- plan_name: str63; { file name }
- end;
-
- var
- prefs: prefsRecord;
-
- procedure SegmentPrefs;
- procedure GetPrefPlan;
- procedure ValidatePrefs (var prefs: prefsRecord);
-
- implementation
-
- uses
- MyUtils;
-
- {$S Prefs}
- procedure SegmentPrefs;
- begin
- end;
-
- {$S Prefs}
- procedure GetPrefPlan;
- var
- oe: OSErr;
- vrn: integer;
- crdate: longInt;
- pb: HParamBlockRec;
- begin
- with prefs do begin
- if (plan_volume = '') or (plan_dirID = -1) or (plan_name = '') then
- oe := -1
- else begin
- vrn := 0;
- oe := GetVolInfo(plan_volume, vrn, -1, crdate);
- if (oe = noErr) and (crdate <> plan_crdate) then
- oe := -1;
- if oe = noErr then begin
- with pb do begin
- ioNamePtr := @plan_name;
- ioVRefNum := vrn;
- ioDirID := plan_dirID;
- ioFDirIndex := 0;
- end;
- oe := PBHGetFInfo(@pb, false);
- end;
- end;
- if oe = noErr then begin
- plan_vrn := vrn;
- end
- else begin
- plan_enabled := false;
- plan_vrn := 0;
- plan_volume := '';
- plan_dirID := -1;
- plan_name := '';
- end;
- end;
- end;
-
- {$S Prefs}
- procedure ValidatePrefs (var prefs: prefsRecord);
- var
- i: integer;
- begin
- with prefs do begin
- if version <> prefs_version then begin
- version := prefs_version;
- showIP := false;
- autoopen := false;
- plan_enabled := false;
- plan_dirID := -1;
- end;
- for i := 3 to 15 do
- dummy[i] := false;
- end;
- GetPrefPlan;
- end;
-
- end.